import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;

import javax.swing.JPanel;

import edu.jhu.tcj.purfuit.Game;
import edu.jhu.tcj.purfuit.Player;
import edu.jhu.tcj.purfuit.Turn;
import edu.jhu.tcj.purfuit.Turn.TurnState;


public class ArrowUI extends JPanel implements PropertyChangeListener{

	private int size = 50;
	
	private final Player player;
	private final Game game;

	public ArrowUI(Player player, Game game) {
		this.player = player;
		this.game = game;
		this.game.addPropertyChangeListener(Turn.TURN_STATE_UPDATE, this);
	}

	public void paintComponent(Graphics graphics) {
		super.paintComponent(graphics);
		Graphics2D g = (Graphics2D)graphics;
		g.setColor(Color.lightGray);
		g.fillRect(0, 0, size, size);
		if(game.getPlayersTurn() == player) {
			g.setColor(player.getColor());
			int[] xPoints = {2,30,30, 50,30,30,2};
			int[] yPoints = {20,20,6,25,44,30,30};
			g.fillPolygon(xPoints, yPoints, 7);
		}
	}
	
	
	@Override
	public void propertyChange(PropertyChangeEvent evt) {
		Object newValue = evt.getNewValue();
		if (newValue instanceof TurnState) {
			TurnState turnState = (TurnState)newValue;
			switch (turnState) {
				case WaitingToRoll:
					break;
				case WaitingToChooseSpace:
					break;
				case WaitingToAnswerQuestion:
					break;
				case TurnOver:
					break;
			}
			repaint();
		}
	}
	
}
